home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / MCIWND.PAK / MCIWND.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  4KB  |  156 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1995, 1995 by Borland International, All Rights Reserved
  4. //
  5. // Definition of TMCIWnd class
  6. //----------------------------------------------------------------------------
  7. #if !defined(OWL_MCIWND_H)
  8. #define OWL_MCIWND_H
  9.  
  10. #if !defined(OWL_DEFS_H)
  11. # include <owl/defs.h>
  12. #endif
  13.  
  14. #if !defined(BI_PLAT_WIN32)
  15. #error This example must be built as a WIN32 Target
  16. #endif
  17.  
  18. // VFW.H relies on some macros which may not be defined by the 
  19. // BORLAND C++ compiler.
  20. //
  21. #if defined(__BORLANDC__)  
  22. # define __inline  inline
  23. # if defined(__WIN32__) && !defined(_WIN32)    
  24. #   define _WIN32
  25. # endif
  26. #endif
  27. #if !defined(_INC_VFW)
  28. # include <vfw.h>
  29. #endif
  30.  
  31. #if !defined(OWL_CONTROL_H)
  32. # include <owl/control.h>
  33. #endif
  34.  
  35. //
  36. // The MCI Wnd procs are strangely __cdecl, so we need custom TModuleProc
  37. // templates for them
  38. //
  39.  
  40. //
  41. template <class R>
  42. class TModuleProc0V : public TModuleProc {
  43.   public:
  44.     TModuleProc0V(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  45.  
  46.     R operator ()() {
  47.       typedef R (far VFWAPIV* TProc)();
  48.       return ((TProc)Proc)();
  49.     }
  50. };
  51.  
  52. //
  53. template <class R, class P1, class P2, class P3, class P4>
  54. class TModuleProc4V : public TModuleProc {
  55.   public:
  56.     TModuleProc4V(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  57.  
  58.     R operator ()(P1 p1, P2 p2, P3 p3, P4 p4) {
  59.       typedef R (far VFWAPIV* TProc)(P1 p1, P2 p2, P3 p3, P4 p4);
  60.       return ((TProc)Proc)(p1, p2, p3, p4);
  61.     }
  62. };
  63.  
  64. //
  65. // class TMciWndDll
  66. // ~~~~~ ~~~~~~~~~~
  67. class _OWLCLASS TMciWndDll : public TModule {
  68.   public:
  69.     TMciWndDll();
  70.  
  71.     TModuleProc4V<HWND,HWND,HINSTANCE,DWORD,LPCSTR> Create;
  72.     TModuleProc0V<BOOL>                             RegisterClass;
  73. };
  74.  
  75. //
  76. // class TMciWnd
  77. // ~~~~~ ~~~~~~~
  78. class _OWLCLASS TMciWnd : public TControl {
  79.   public:
  80.     TMciWnd(TWindow* parent, int id, char far* title, 
  81.             int x, int y, int w, int h, TModule* module = 0);
  82.     TMciWnd(TWindow* parent, int resourceId, TModule* module = 0);
  83.  
  84.     bool        Open(char far* fileOrDevice, uint flags = 0);
  85.     bool        OpenDialog();
  86.     uint32      Close();
  87.     uint32      Play();
  88.     uint32      Stop();
  89.     uint32      Pause();
  90.     uint32      Resume();
  91.     uint32      Seek(long pos);
  92.  
  93.     // Overriden virtuals of TWindow
  94.     //
  95.     char far*   GetClassName();
  96.     bool        Register();
  97.  
  98.   protected:
  99.     TMciWndDll  MciWndDll;
  100. };
  101.  
  102. //----------------------------------------------------------------------------
  103. // Inline implementations
  104. //
  105.  
  106. //
  107. inline bool TMciWnd::Open(char far* fileOrDevice, uint flags)
  108. {
  109.   PRECONDITION(GetHandle());
  110.   return MCIWndOpen(*this, fileOrDevice, flags) != 0;
  111. }
  112.  
  113. //
  114. inline uint32 TMciWnd::Close()
  115. {
  116.   PRECONDITION(GetHandle());
  117.   return MCIWndClose(*this);
  118. }
  119.  
  120. //
  121. inline uint32 TMciWnd::Play()
  122. {
  123.   PRECONDITION(GetHandle());
  124.   return MCIWndPlay(*this);
  125. }
  126.  
  127. //
  128. inline uint32 TMciWnd::Stop()
  129. {
  130.   PRECONDITION(GetHandle());
  131.   return MCIWndStop(*this);
  132. }
  133.  
  134. //
  135. inline uint32 TMciWnd::Pause()
  136. {
  137.   PRECONDITION(GetHandle());
  138.   return MCIWndPause(*this);
  139. }
  140.  
  141. //
  142. inline uint32 TMciWnd::Resume()
  143. {
  144.   PRECONDITION(GetHandle());
  145.   return MCIWndResume(*this);
  146. }
  147.  
  148. //
  149. inline uint32 TMciWnd::Seek(long pos)
  150. {
  151.   PRECONDITION(GetHandle());
  152.   return MCIWndSeek(*this, pos);
  153. }
  154.  
  155. #endif  // OWL_MCIWND_H
  156.